#ifndef __THREAD_H__
#define __THREAD_H__

#include <string>
#include <boost/utility.hpp>
#include <boost/function.hpp>

namespace mars {

class Thread : boost::noncopyable {
    public:
        typedef boost::function<void ()> ThreadFunc;
        explicit Thread(const ThreadFunc& func, const std::string& name = std::string());
        ~Thread();
        void start();
        void join();
        std::string name();
        pid_t tid();
    private:
        ThreadFunc _func;
        pid_t _tid;
        pthread_t _pthread_id;
        std::string _name;
        bool _started;
        bool _joined;
};

namespace CurrentThread {
    const char* name();
    pid_t tid();
    bool is_main_thread();
} // namespace CurrentThread

} // namespace mars

#endif //__THREAD_H__
